<template>
  <div class="commitBidFile">
    <el-row>
      <el-col :span="8">
        <span class="label">企业名称：</span>
        <span class="text">{{ enterpriseData.name }}</span>
      </el-col>
      <el-col :span="16">
        <span class="label">统一社会信用代码：</span>
        <span class="text">{{ enterpriseData.usci }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">公司注册地址：</span>
        <span class="text">{{ enterpriseData.address }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <span class="label">机构类型：</span>
        <span class="text">{{ getDictValue(enterpriseData.affiliation,'enterpriseAffiliation') }}</span>
      </el-col>
      <el-col :span="8">
        <span class="label">企业性质：</span>
        <span class="text">{{ getDictValue(enterpriseData.enterpriseNature,'enterpriseNature') }}</span>
      </el-col>
      <el-col :span="8">
        <span class="label">成立日期：</span>
        <span class="text">{{ parseTime(enterpriseData.doe, '{y}年{m}月{d}日') }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <span class="label">法人/负责人：</span>
        <span class="text">{{ enterpriseData.corpn }}</span>
      </el-col>
      <el-col :span="16">
        <span class="label">法人/负责人身份证：</span>
        <span class="text">{{ enterpriseData.corpnIdcard }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">法人/负责人身份证扫描件：</span>
        <span class="text">
          <el-button type="text" style="color: #17c2aa;" @click="showImage(enterpriseData.corpnIdcardImage,'法人/负责人身份证扫描件')">查看图片</el-button>
        </span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">单位联系地址：</span>
        <span class="text">{{ enterpriseData.contactAddress }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <span class="label">经营范围：</span>
        <span class="text">{{ enterpriseData.businessScope }}</span>
      </el-col>
      <el-col :span="16">
        <span class="label">公司简介：</span>
        <span class="text">{{ enterpriseData.profile }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">营业执照有效期：</span>
        <span class="text">{{ enterpriseData.businessLicenseGp }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">营业执照扫描件：</span>
        <span class="text">
          <el-button type="text" style="color: #17c2aa;" @click="showImage(enterpriseData.businessLicenseImage,'营业执照扫描件')">查看图片</el-button>
        </span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <span class="label">开户行：</span>
        <span class="text">{{ enterpriseData.bank }}</span>
      </el-col>
      <el-col :span="16">
        <span class="label">银行账号：</span>
        <span class="text">{{ enterpriseData.account }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">开户行地址：</span>
        <span class="text">{{ enterpriseData.addr }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <span class="label">单位注册电话：</span>
        <span class="text">{{ enterpriseData.registrationPhone }}</span>
      </el-col>
      <el-col :span="16">
        <span class="label">单位注册地址：</span>
        <span class="text">{{ enterpriseData.contactAddr }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="8">
        <span class="label">注册资本（万元）：</span>
        <span class="text">{{ enterpriseData.registeredCapital }}</span>
      </el-col>
      <el-col :span="16">
        <span class="label">实缴资本：</span>
        <span class="text">{{ enterpriseData.paidinCapital }}</span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">开户许可证/基本户存款信息证：</span>
        <span class="text">
          <el-button type="text" style="color: #17c2aa;" @click="showImage(enterpriseData.accountLicence,'开户许可证/基本户存款信息证')">查看图片</el-button>
        </span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <span class="label">上传文件：</span>
        <span class="text">
          <FileUpload
            :file-type="fileType"
            :limit="fileLimit"
            :file-size="fileSize"
            :is-show-file-list="true"
            :is-show-tip="true"
            v-model="fileList"
          />
        </span>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div style="width: 1200px;display: flex;flex-direction: row-reverse;">
          <el-button style="background: #17C2AA;width: 72px;height: 32px;border-radius: 4px;color: #FFFFFF;" @click="handleUpdate">
            提交
          </el-button>
        </div>
      </el-col>
    </el-row>

    <el-dialog :visible.sync="isShow" :title="imageTitle" width="800px" append-to-body>
      <el-image :src="imageUrl" style="width: 100%;">
        <div slot="image-slot">
          加载中...
        </div>
      </el-image>
    </el-dialog>
  </div>
</template>

<script>
import {getBidding,updateBidding} from '@/api/bid/enterprise'
import FileUpload from '@/components/FileUpload'

export default {
  name: "commitBidFile",
  components:{FileUpload},
  data() {
    return {
     id:null,
     enterpriseData:{
      name:null
     },
     enterpriseAffiliation:[],
     enterpriseNature:[],

     isShow:false,
     imageTitle:'',
     imageUrl:'',

     fileList:[],
     fileType: ['pdf', 'zip', 'rar', 'png', 'jpg', 'jpeg'],
     fileLimit: 10,
     fileSize: 100,
    }
  },
  created() {
    this.id = this.$route.query.id
    getBidding(this.id).then(res=>{
      console.log(res);
      this.enterpriseData = res.data.enterprise
    })
    this.getDicts('enterprise_affiliation').then(response => {
      this.enterpriseAffiliation = response.data
    })
    this.getDicts('enterprise_nature').then(response => {
      this.enterpriseNature = response.data
    })
  },
  mounted() {
    
  },
  methods: {
    handleUpdate() {
      if (this.fileList == null || this.fileList.length === 0) {
        return;
      }
      const files = []
      this.fileList.map(x => {
        files.push({
          enterpriseBidId: this.bidId,
          fileName: x.originalFileName,
          filePath: x.url
        })
      })
      const bidEnterpriseBidding = {
        id: this.id,
        enterpriseId: this.enterpriseData.id,
        filesList: files
      }
      console.log(bidEnterpriseBidding);
      updateBidding(bidEnterpriseBidding).then(x => {
        this.$alert('报名成功', '提示', {
          confirmButtonText: '确定',
          type: "success",
          callback: () => {
            this.$router.replace('/enterprise/myBidding')
          }
        });
      })
    },
    showImage(path,name){
      this.imageTitle = name
      this.imageUrl = path
      this.isShow = true
    },
    getDictValue(key, type) {
      const value = this[type].filter(x => x.dictValue === key);
      if (value != null && value.length > 0) {
        return value[0].dictLabel;
      }
      return ''
    }
  }
}
</script>

<style scoped>
.commitBidFile{
  background-color: #fff;
  padding: 20px;
  margin-left: 25px;
  border-radius: 5px;
}
.el-row{
  margin-bottom: 20px;
}

.el-col {
  display: flex;
}
.text{
  color: #666;
}
</style>
